<template>
	<tab-bar>
		<nav-bar title="首页"></nav-bar>
		<view class="text-area">
			首页
			<u-button :ripple="true" @click="click">登录页</u-button>
			<u-button :ripple="true" bindtap="getUserProfile" @click="getUserProfile">获取用户信息</u-button>
		</view>
	</tab-bar>
</template>

<script>
	import {getProvider,login,getUserInfo,getUserProfile} from '../../request.js'
	export default {
		data() {
			return {
				title: 'Hello'
			}
		},
		onLoad() {
			let provider = ''
			let code = ''
			getProvider({service:'oauth'})
			.then(res=>{
				console.log(res)
				provider = res[0]
				return login({provider})
			})
			.then(res=>{
				console.log(res)
				code = res.code
				return getUserInfo({provider})
			})
			.then(res=>{
				console.log(res)
			})
			.catch(err=>{
				console.log(err)
			})
		},
		onShow(){
			
		},
		onHide(){
			console.log(111)
		},
		mounted() {

		},
		methods: {
			click(){
				uni.navigateTo({
					url:'/pages/login/index'
				})
			},
			getUserProfile(){
				getUserProfile({desc:'获取头像及昵称信息'}).then(res=>{
					console.log(res)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.text-area{
		font-size: 32rpx;
	}
	/deep/ .u-btn{
		width: 200rpx;
	}
</style>
